TARGET = obj
CC = gcc
CFLAGS = -Wall -c

SOURCE = main.c func.c
#OBJ = $(SOURCE:.c=.o)
#subst 函数，用来完成字符串替换  $(subst <old_str>,<new_str>,<text>)
#OBJ = $(subst .c,.o,$(SOURCE))

#patsubst 函数用来完成模式字符串替换 $(patsubst src,dst,text>)
OBJ = $(patsubst %.c,%.o,$(SOURCE))


$(TARGET):$(OBJ)
	$(CC) $(OBJ) -o $(TARGET)

%.o:%.c
	$(CC) $(CFLAGS) $<

print:
	@echo $(OBJ)

#伪目标
.PHONY:clean

clean:
	rm -rf *.o $(TARGET)
